package com.ylzinfo.ms.fetchdemo.TestOkhttp;

import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * @Description:
 * @Product: IntelliJ IDEA
 * @Author Rogchen rogchen128@gmail.com
 * @Created Date: 20-2-11 17:29
 **/
@Slf4j
public class TestOkhttp {

    String url = "https://ssc.mohrss.gov.cn/cardInfo/PagePlague/pagePlagueList";

    public void testOk() throws IOException {
        OkHttpClient okHttpClient = new OkHttpClient();
        final Request request = new Request.Builder()
                .url(url)
                .get()//默认就是GET请求，可以不写
                .build();
        Response response = okHttpClient.newCall(request).execute();
        if (response.isSuccessful()) {
            log.info(response.toString());
        }
    }
}
